module.exports = function (platform, isDevelopment) {

    
    const babelOptions = {
        presets: [
            [
                '@babel/preset-env', {
                    modules: 'commonjs' 
                }
            ]
        ],
        plugins: [
            '@babel/plugin-transform-runtime',

            // 必须放在syntax-decorators前
            'yaxi/dev/babel/plugin-property',

            // 必须放在proposal-class-properties前
            ['@babel/plugin-syntax-decorators', { 'legacy': true }],
            '@babel/plugin-proposal-class-properties',

            // 必须要放在最后
            'yaxi/dev/babel/plugin-jsx'
        ]
    };


    return [
        {
            test: /\.js$/,
            exclude: /node_modules/,
            use: [
                {
                    loader: 'babel-loader',
                    options: babelOptions
                }
            ]
        },
        {
            test: /\.jsx$/,
            exclude: /node_modules/,
            use: [
                {
                    loader: 'babel-loader',
                    options: babelOptions
                }
            ]
        },
        {
            test: /\.tsx?$/,
            exclude: /node_modules/,
            use: [
                {
                    loader: 'babel-loader',
                    options: babelOptions
                },
                {
                    loader: 'ts-loader' 
                }
            ]
        },
        {
            test: /\.css$/,
            use: [
                {
                    loader: 'mini-css-extract-plugin/dist/loader'
                },
                {
                    loader: 'css-loader'
                }
            ]
        },
        {
            test:/[\\/]icon[\\/]([\s\S]+)?\.(ttf|eot|otf|svg|woff2?)$/,
            use: [
                {
                    loader: 'file-loader?limit=8192&name=icon/[name]-[contenthash:20].[ext]'
                }
            ]
        },
        {
            test: /\.(jpe?g|png|gif|svg)$/, 
            exclude: /icon/,
            use: [
                {
                    loader: 'url-loader?limit=8192&name=assets/images/[name]-[contenthash:20].[ext]'
                }
            ]
        },
        {
            test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)$/,
            use: [
                {
                    loader: 'url-loader?limit=8192&name=assets/media/[name]-[contenthash:20].[ext]'
                }
            ]
        }
    ];
}
